

objectdef obj_Settings_Loader
{
	variable string SettingFile = "${Script.CurrentDirectory}/settings/settings.xml"
	variable settingsetref PrivateC
	variable settingsetref GlobalC
	
	method Initialize()
	{	
		LavishSettings[HNSets]:Clear
		LavishSettings:AddSet[HNSets]
		LavishSettings[HNSets]:AddSet[${LoginScript.Username}]
		LavishSettings[HNSets]:AddSet[Global]
		LavishSettings[HNSets]:Import[${SettingFile}]
	
		PrivateC:Set[${LavishSettings[HNSets].FindSet[${LoginScript.Username}]}]
		GlobalC:Set[${LavishSettings[HNSets].FindSet["Global"]}]
		UI:UpdateConsole["Settings: Loaded"]
	}
	
	method Shutdown()
	{
		This:Save[]
		LavishSettings[EVEBotSettings]:Clear
	}

	method Save()
	{
		LavishSettings[EVEBotSettings]:Export[${SettingFile}]
	}		
}

objectdef obj_Settings_Private
{
	variable string SettingsName = "Private"
	
	method Initialize()
	{	
		if !${PrivateC.Private.FindSet[${This.SettingsName}](exists)}
		{
			UI:UpdateConsole["Warning: ${This.SettingsName} settings missing"]
			This:Set_Default_Values[]
		}
		UI:UpdateConsole["Private Settings: Loaded"]
	}
	
	member:settingsetref PrivateRef()
	{
		return ${PrivateC.Private.FindSet[${This.SettingsName}]}
	}
	
	method Set_Default_Values()
	{
		PrivateC.Private:AddSet[${This.SettingsName}]
		
		This.PrivateRef:AddSetting[My Name, ${LoginScript.Username}]
	}
}

objectdef obj_Settings_Public
{
	variable string SettingsName = "Public"
	
	method Initialize()
	{	
		if !${PublicC.Public.FindSet[${This.SettingsName}](exists)}
		{
			UI:UpdateConsole["Warning: ${This.SettingsName} settings missing"]
			This:Set_Default_Values[]
		}
		UI:UpdateConsole["Public Settings: Loaded"]
	}
	
	member:settingsetref PublicRef()
	{
		return ${PublicC.Public.FindSet[${This.SettingsName}]}
	}
	
	method Set_Default_Values()
	{
		PublicC.Public:AddSet[${This.SettingsName}]
		
		This.PublicRef:AddSetting[${LoginScript.Username} Corporation, TESTER]
	}
}

objectdef obj_Settings
{
	variable obj_Settings_Private Private
	variable obj_Settings_Global Global
		
	method Initialize()
	{
	}
	
	method PrivateSave()
	{
		Private:Save[]
	}
	
	method GlobalSave()
	{
		Global:Save[]
	}
}





